package cn.tedu.jdbc;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class JDBCUtils {
    /**
     * close():用来释放jdbc的资源
     * @param rs
     * @param ps
     * @param conn
     */
    public  static void close(ResultSet rs , PreparedStatement ps, Connection conn){
        if (rs != null){
            try {

                rs.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }finally {
                rs =null;
            }
        }

        if (ps != null){
            try {
                ps.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }finally {
                ps=null;
            }
        }
        if (conn !=null){
            try {
                conn.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }finally {
                conn=null;
            }
        }
    }
}
